﻿@model ChangePasswordModel
@using Urs.Web.Models.User;
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">编辑我的资料</div>
                    <div class="layui-card-body" pad15>

                        <div class="layui-form" lay-filter="layuiadmin-form-user" id="layuiadmin-form-user" style="padding: 20px 30px 0 0;">
                            <div class="layui-form-item">
                                <label style="float:left;width:105px;margin-top:7px">当前密码</label>
                                <div class="layui-input-inline">
                                    <u-editor asp-for="OldPassword" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label style="float:left;width:105px;margin-top:7px">新密码</label>
                                <div class="layui-input-inline">
                                    <u-editor asp-for="NewPassword" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label style="float:left;width:105px;margin-top:7px">再次输入新密码</label>
                                <div class="layui-input-inline">
                                    <u-editor asp-for="ConfirmNewPassword" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="set_system_submit_btn">确认保存</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

<script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form'], function () {
            var $ = layui.$
                , form = layui.form;
            //监听提交
            form.on('submit(set_system_submit_btn)', function (data) {
                var index = layer.load(2, { shade: false });
                    var field = data.field; //获取提交的字段
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    //提交 Ajax 成功后，关闭当前弹层并重载表格
                    $.post('@Url.Action("ChangePassword")', field, function (rep) {
                        if (rep.success == 1) {
                            layer.msg('保存成功');
                            parent.layui.table.reload('LAY-user-list'); //重载表格
                            parent.layer.close(index); //再执行关闭
                        }
                        if (rep.success == 2) {
                            layer.msg('密码错误');
                        }
                    });
            });
        })
</script>
